package com.HuaweiTest;

import java.util.HashSet;
import java.util.Scanner;

public class DanRukou {
    static int rows;
    static int cols;
    static String[][] grid;
    static int[][] directions = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
    static HashSet<String> visited = new HashSet<>();
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        rows = sc.nextInt();
        cols = sc.nextInt();
        grid = new String[rows][cols];
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                grid[i][j] = sc.next();
            }
        }
        findLargestConnectedArea(grid, rows, cols);
    }
    public static void findLargestConnectedArea(String[][] grid, int rows, int cols) {
        int maxSize = 0;
        int entranceRow = -1;
        int entranceCol = -1;
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                if (grid[i][j].equals("O") && (i == 0 || i == rows - 1 || j == 0 || j == cols - 1)) {
                    int size = dfs(grid, rows, cols, i, j);
                    if (size > maxSize) {
                        maxSize = size;
                        entranceRow = i;
                        entranceCol = j;
                    }
                }
            }
        }
        if (maxSize == 0) {
            System.out.println("NULL");
        } else {
            System.out.println(entranceRow + " " + entranceCol + " " + maxSize);
        }
    }
    public static int dfs(String[][] grid, int rows, int cols, int row, int col) {
        if (row < 0 || row >= rows || col < 0 || col >= cols || grid[row][col].equals("X") || visited.contains(row + "," + col)) {
            return 0;
        }
        visited.add(row + "," + col);
        int size = 1;
        for (int[] dir : directions) {
            int newRow = row + dir[0];
            int newCol = col + dir[1];
            size += dfs(grid, rows, cols, newRow, newCol);
        }
        return size;
    }
}